package com.zmz.Stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2023/01/29/14:35
 * @Description: 求两个集合的差集
 */
public class differenceOfList {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        List<String> list1 = new ArrayList<String>();
        list1.add("java265.com-1");
        list1.add("java265.com-2");
        list1.add("java265.com-3");

        List<String> list2 = new ArrayList<String>();
        list2.add("java265.com-8");
        list2.add("java265.com-2");
        list2.add("java265.com-9");


        System.out.println("======================");
        System.out.println(!list2.contains("java265.com-2"));
        // list1 差集
        list1 = list1.stream().filter(e -> {
            return !list2.contains(e);
        }).collect(Collectors.toList());
        System.out.println(list1);

    }
}
